<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Tabbar extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('tab_bar')
            ->setComment('底部导航')
            ->addColumn(Column::string('name', 4)->setComment('名称'))
            ->addColumn(Column::string('unselect_image')->setComment('未选中图标'))
            ->addColumn(Column::string('selected_image')->setComment('选中图标'))
            ->addColumn(Column::enum('jump_type', [0, 1, 2, 3])->setComment('跳转方式:0=不跳转,1=内部页面,2=H5,3=小程序')->setDefault('0'))
            ->addColumn(Column::string('path')->setComment('跳转链接')->setNullable())
            ->addColumn(Column::string('app_id')->setComment('小程序appId')->setNullable())
            ->addColumn(Column::string('extra_array')->setComment('额外参数')->setNullable())
            ->addColumn(Column::integer('weigh')->setDefault(0)->setComment('排序'))
            ->addColumn(Column::enum('status', [0, 1])->setComment('状态:0=关闭,1=开启')->setDefault('0'))
            ->addColumn(Column::bigInteger('create_time')->setNullable()->setComment('创建时间'))
            ->addColumn(Column::bigInteger('update_time')->setNullable()->setComment('更新时间'))
            ->create();
    }
}
